<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>


<script>
/**
 * 工厂函数
 * 实例化一个对象，然后返回一个对象
 * 类似于一个机器批量生产一个产品，产品的功能一致
 */
function createStudent(name, age, sex) {
	var student = new Object();
	student.name = name;
	student.age = age;
	student.sex = sex;
	student.say = function() {
		console.log('hello world')
	}
	return student;
}
var student1 = createStudent('小花', 18, '女')
var student2 = createStudent('小明', 19, '男')

/**
 * 构造函数
 * this来初始化值，用new实例化一个对象
 * 一般用途：初始化某类产品的相同的功能，
 * 各个产品可以额外扩展自己的功能
 * 
 */
function Persoon(name, age, sex) {
	this.name = name;
	this.age = age;
	this.sex = sex;
	this.say = = function() {
		console.log('hello world')
	}
}

var xm = new Persoon('小花', 18, '女');

</script>
</body>
</html>